package com.swanclouds.redfish.systems.domain;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonRootName;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.swanclouds.redfish.common.redfish.MemberModel;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author 张立强
 *
 */
public class StorageModel {

    @JsonProperty("StorageControllers@odata.count")
    private Integer storageControllersCount;
    /**
     * 存储控制器个数
     *
     * @return storageControllersCount
     */
   
    public Integer getStorageControllersCount() {
        return this.storageControllersCount;
    }

    @JsonProperty("StorageControllers")
    private List<StorageControllerModel> storageControllers;
    /**
     * 存储控制器列表
     * @see com.swanclouds.model.systems.Storage.StorageController
     * @return storageControllers
     */
   
    public List<StorageControllerModel> getStorageController() {
        List<StorageControllerModel> list = new ArrayList<>();
        if (this.storageControllers != null && this.storageControllers.size() > 0) {
            this.storageControllers.stream().forEach(sc -> {
                list.add(sc);
            });
        }
        return list;
    }

    @JsonProperty("Drives@odata.count")
    private Integer driversCount;
    /**
     * 存储控制器管理的驱动器个数
     *
     * @return driversCount
     */
   
    public Integer getDrivesCount() {
        return this.driversCount;
    }

    @JsonProperty("Drives")
    private List<MemberModel> drivers;
    /**
     * 定控制器管理的驱动器列表
     *
     * @return Drives
     */
   
    public List<String> getDrives() {
        return this.drivers.stream().map(MemberModel::getDataId).collect(Collectors.toList());
    }

    @JsonProperty("Volume@odata.count")
    private Integer volumesCount;
    /**
     * 存储控制器管理的逻辑盘集合资源个数
     *
     * @return volumesCount
     */
   
    public Integer getVolumesCount() {
        return this.volumesCount;
    }

    @JsonProperty("Volumes")
    private List<MemberModel> volumes;
    /**
     * 控制器管理的逻辑盘集合资源
     *
     * @return volumes
     */
   
    public List<String> getVolumes() {
        return this.volumes.stream().map(MemberModel::getDataId).collect(Collectors.toList());
    }

    @JsonProperty("@odata.id")
    private String dataId;
    /**
     * 系统资源的访问路径 @odata.id
     *
     * @return dataidId
     */
   
    public String getDataId() {
        return this.dataId;
    }

    @JsonProperty("@odata.context")
    private String context;
    /**
     * 系统资源模型的OData描述信息 @odata.context
     *
     * @return context
     */
   
    public String getContext() {
        return this.context;
    }

    @JsonProperty("@odata.type")
    private String type;
    /**
     * 系统资源的类型 @odata.type
     *
     * @return type
     */
   
    public String getType() {
        return this.type;
    }

    @JsonProperty("Id")
    private String id;
    /**
     * 系统资源的ID Id
     *
     * @return id
     */
   
    public String getId() {
        return this.id;
    }

    @JsonProperty("Name")
    private String name;
    /**
     * 系统资源的名称 Name
     *
     * @return name
     */
   
    public String getName() {
        return this.name;
    }

    @JsonRootName("StorageController")
    public static class StorageControllerModel {

        @JsonProperty("MemberId")
        private Integer memberId;

        /**
         * 控制器标识
         *
         * @return memberId
         */
       
        public Integer getMemberId() {
            return this.memberId;
        }

        @JsonProperty("@odata.id")
        private String dataId;
        /**
         * 存储控制器的访问路径
         *
         * @return dataId
         */
       
        public String getDataId() {
            return this.dataId;
        }

        @JsonProperty("Description")
        private String description;
        /**
         * 存储控制器的描述信息
         *
         * @return description
         */
       
        public String getDescription() {
            return this.description;
        }

        @JsonProperty("Name")
        private String name;
        /**
         * 存储控制器的名称
         *
         * @return name
         */
       
        public String getName() {
            return this.name;
        }

        @JsonProperty("Status")
        private StatusModel status;
        /**
         * 存储控制器的状态
         *
         * @return status
         */
       
        public StatusModel getStatus() {
            return this.status;
        }

        @JsonProperty("SerialNumber")
        private String serialNumber;
        /**
         * 存储控制器序列号
         *
         * @return serialNumber
         */
       
        public String getSerialNumber() {
            return this.serialNumber;
        }

        @JsonProperty("SpeedGbps")
        private Integer speedGbps;
        /**
         * 存储控制器的接口速率
         *
         * @return speedGbps
         */
       
        public Integer getSpeedGbps() {
            return this.speedGbps;
        }

        @JsonProperty("FirmwarePackageVersion")
        private String firmwarePackageVersion;
        /**
         * 存储控制器的固件版本
         *
         * @return firmwarePackageVersion
         */
       
        public String getFirmwarePackageVersion() {
            return this.firmwarePackageVersion;
        }

        @JsonProperty("SupportedDeviceProtocols")
        List<String> supportedDeviceProtocols;
        /**
         * 存储控制器支持的协议类型
         *
         * @return supportedDeviceProtocols
         */
       
        public List<String> getSupportedDeviceProtocols() {
            return this.supportedDeviceProtocols;
        }

        @JsonProperty("Manufacturer")
        private String manufacturer;
        /**
         * 存储控制器生产厂商
         *
         * @return manufacturer
         */
       
        public String getManufacturer() {
            return this.manufacturer;
        }

        @JsonProperty("Model")
        private String model;

        /**
         * 存储控制器型号
         *
         * @return model
         */

       
        public String getModel() {
            return this.model;
        }

        @JsonProperty("Oem")
        private Oem oem;

        /**
         * 存储控制器自定义参数
         * @return oem
         */
       
        public Oem getOem() {
            return this.oem;
        }

        public static class StatusModel {

            @JsonProperty("State")
            private String state;

            @JsonProperty("Health")
            private String health;

            /**
             * 存储控制器使能状态
             *
             * @return state
             */
           
            public String getState() {
                return this.state;
            }

            /**
             * 存储控制器健康状态
             *
             * @return health
             */
           
            public String getHealth() {
                return this.health;
            }

           
            public String toString() {
                ObjectMapper objectMapper = new ObjectMapper();
                try {
                    return objectMapper.writeValueAsString(this);
                } catch (JsonProcessingException e) {
                }
                return "StatusModel {" +
                        "state='" + state + '\'' +
                        ", health='" + health + '\'' +
                        '}';
            }
        }

        @JsonRootName("Oem")
        public static class Oem {

            @JsonProperty("BMC")
            private Bmc bmc;

            @JsonProperty("Huawei")
            private Huawei huawei;

            public Bmc getBmc() {
                return this.bmc;
            }

            public void setBmc(Bmc bmc) {
                this.bmc = bmc;
            }

            public Huawei getHuawei() {
                return this.huawei;
            }

            public void setHuawei(Huawei huawei) {
                this.huawei = huawei;
            }

            @JsonRootName("BMC")
            public static class Bmc {

                @JsonProperty("SupportedRAIDLevels")
                private List<String> supportedRAIDLevels;

                @JsonProperty("SASAddress")
                private String sasAddress;

                @JsonProperty("MemorySizeMiB")
                private Long memorySizeMiB;
                @JsonProperty("CapacitanceName")
                private String capacitanceName;

                @JsonProperty("CapacitanceStatus")
                private CapacitanceStatus capacitanceStatus;

                public List<String> getSupportedRAIDLevels() {
                    return this.supportedRAIDLevels;
                }

                public void setSupportedRAIDLevels(List<String> supportedRAIDLevels) {
                    this.supportedRAIDLevels = supportedRAIDLevels;
                }

                public String getSasAddress() {
                    return this.sasAddress;
                }

                public void setSasAddress(String sasAddress) {
                    this.sasAddress = sasAddress;
                }

                public Long getMemorySizeMiB() {
                    return this.memorySizeMiB;
                }

                public void setMemorySizeMiB(Long memorySizeMiB) {
                    this.memorySizeMiB = memorySizeMiB;
                }

                public String getCapacitanceName() {
                    return this.capacitanceName;
                }

                public void setCapacitanceName(String capacitanceName) {
                    this.capacitanceName = capacitanceName;
                }

                public CapacitanceStatus getCapacitanceStatus() {
                    return this.capacitanceStatus;
                }

                public void setCapacitanceStatus(CapacitanceStatus capacitanceStatus) {
                    this.capacitanceStatus = capacitanceStatus;
                }

                @JsonRootName("CapacitanceStatus")
                public static class CapacitanceStatus {
                    @JsonProperty("State")
                    private String state;
                    @JsonProperty("Health")
                    private String health;

                    public String getState() {
                        return this.state;
                    }

                    public void setState(String state) {
                        this.state = state;
                    }

                    public String getHealth() {
                        return this.health;
                    }

                    public void setHealth(String health) {
                        this.health = health;
                    }
                }
            }

            @JsonRootName("Huawei")
            public static class Huawei {
                @JsonProperty("SASAddress")
                private String sasAddress;

                @JsonProperty("MemorySizeMiB")
                private Long memorySizeMiB;

                public String getSasAddress() {
                    return this.sasAddress;
                }

                public void setSasAddress(String sasAddress) {
                    this.sasAddress = sasAddress;
                }

                public Long getMemorySizeMiB() {
                    return this.memorySizeMiB;
                }

                public void setMemorySizeMiB(Long memorySizeMiB) {
                    this.memorySizeMiB = memorySizeMiB;
                }
            }
        }

       
        public String toString() {
            ObjectMapper objectMapper = new ObjectMapper();
            try {
                return objectMapper.writeValueAsString(this);
            } catch (JsonProcessingException e) {
            }
            return "StorageControllerModel {" +
                    "memberId=" + memberId +
                    ", dataId='" + dataId + '\'' +
                    ", description='" + description + '\'' +
                    ", name='" + name + '\'' +
                    ", status=" + status +
                    ", serialNumber='" + serialNumber + '\'' +
                    ", speedGbps=" + speedGbps +
                    ", firmwarePackageVersion='" + firmwarePackageVersion + '\'' +
                    ", supportedDeviceProtocols=" + supportedDeviceProtocols +
                    ", manufacturer='" + manufacturer + '\'' +
                    ", model='" + model + '\'' +
                   // ", oem=" + oem +
                    '}';
        }
    }

   
    public String toString() {
        ObjectMapper objectMapper = new ObjectMapper();
        try {
            return objectMapper.writeValueAsString(this);
        } catch (JsonProcessingException e) {
        }
        return "StorageModel {" +
                "storageControllersCount=" + storageControllersCount +
                ", storageControllers=" + storageControllers +
                ", driversCount=" + driversCount +
                ", drivers=" + drivers +
                ", volumesCount=" + volumesCount +
                ", volumes=" + volumes +
                ", dataId='" + dataId + '\'' +
                ", context='" + context + '\'' +
                ", type='" + type + '\'' +
                ", id='" + id + '\'' +
                ", name='" + name + '\'' +
                '}';
    }
}
